package com.sn.shop.controller;

import com.alibaba.fastjson.JSON;
import com.sn.shop.service.UserService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @auther sn
 * @date 2018/1/23
 * @description TODO
 */
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("/{id}")
    public String findByID(@PathVariable("id") int id) {
        return JSON.toJSONString(userService.findById(id));
    }

    @RequestMapping(value = "/changePassword", method = RequestMethod.POST)
    public int changePassword(@RequestParam String newPwd) {
        return userService.changePassword(newPwd);
    }

    @PostMapping("/test")
    public String test() {
        return "test";
    }
}
